<html>
<body>
	<div class="form-group">
		<div class="col-sm-4 col-sm-offset-2">
			<button class="btn btn-primary" type="button" onclick="pay()">模拟支付</button>
		</div>
	</div>
</body>

<script src="js/jquery-1.9.1.js"></script>
<script src="js/pingpp.js"></script>
<script>
	function pay(money) {
		$
		.ajax({
			type : "post",
			url : "${ctx}/getPingppCharge",
			data : "amount=10&channel=alipay_pc_direct&client_ip=127.0.0.1&subject=Test sample&order_desc=Test sample",
			success : function(msg) {
				alert(msg);
				var info = eval('(' + msg + ')');
				if (info.error == "0000") {
					pingpp.createPayment(info.datas, function(result,
						err) {
						console.log(result);
						console.log(err.msg);
						console.log(err.extra);
						if (result == "success") {
									// 只有微信公众账号 wx_pub 支付成功的结果会在这里返回，其他的支付结果都会跳转到 extra 中对应的 URL。
								} else if (result == "fail") {
									// charge 不正确或者微信公众账号支付失败时会在此处返回
								} else if (result == "cancel") {
									// 微信公众账号支付取消支付
								}
							});
				}

			}
		})
	}
</script>
</html>
